import { Effect, ImmerReducer, Reducer, Subscription } from 'umi';
import { orderList } from '@/services';
import { orderLists } from '@/types'

export interface orderFormModelState {
    orderForomList: orderLists[],
    order: any
}
export interface orderFormType {
    namespace: 'orderForm';
    state: orderFormModelState;
    effects: {
        orderList: Effect;
    };
    reducers: {
        save: Reducer<orderFormModelState>;
    };
}
const orderForm: orderFormType = {
    namespace: 'orderForm',
    state: {
        orderForomList: [],
        order: {}
    },
    effects: {
        *orderList({ payload }, { call, put }) {
            let result = yield orderList(payload);
            console.log(result,'订单数据');
            if (result) {
                yield put({
                    type: 'save',
                    payload: {
                        orderForomList: result.records,
                        order: result
                    }
                })
            }
        },
    },
    reducers: {
        save(state, action) {
            return {
                ...state,
                ...action.payload,
            };
        },

    },

};

export default orderForm;